package com.durian.ui.adapter.multi;

import androidx.annotation.NonNull;

import android.app.Application;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;


/**
 * 说明：ItemViewProvider
 * <p/>
 * 作者：fanly
 * <p/>
 * 类型：Class
 * <p/>
 * 时间：2016/11/28 15:11
 * <p/>
 * 版本：version 1.0
 */
public abstract class ItemViewProvider<C> extends ViewProvider<C>{

    private Context mApplication;

    public ItemViewProvider() {
        this(null);
    }

    public ItemViewProvider(Application context) {
        if (context != null){
            mApplication = context.getApplicationContext();
        }
    }

    @NonNull
    @Override
    protected MultiItemViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View view = getItemView(parent.getContext());
        if (view == null){
            view = inflater.inflate(getItemLayoutId(), parent, false);
        }
        return new MultiItemViewHolder(view);
    }

    @Override
    protected ArrayList<ViewProvider> getAllMultiViewProviders() {
        return null;
    }

    @Override
    protected Class withLinker(C item) {
        return null;
    }

    @Override
    public boolean isMultiType() {
        return false;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        mApplication = null;
        mAdapter = null;
    }

    public Context getAppContext(){
        return mApplication;
    }

}
